/*
 *      Fischer Chess Club
 *      Copyright (c) 2010 Ryan Chiu
 *      All rights reserved.
 *      
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package fischer;

import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Fischer {
	public static ServerSocket serversocket;
    public static final int port = 5000;
    public static fischer.List list = new List();
    public static final String prompt = "fics% ";
    
    public static void main(String[] args) {
    	System.out.println("Fischer Chess Club running");
    	
        int nreq = 1;

        try
        {
            serversocket = new ServerSocket(port);
            for(;;)
            {
                Socket socket = serversocket.accept();
                //Database.connect()
                System.out.println("Creating server thread...");
                Thread t = new ThreadHandler(socket, nreq);               
                t.run();
                nreq++;
            }
        } catch (Exception e) { System.out.println("Chess Server Error: "+e); }
    }
    
    public static void goodbye(PrintStream outp)
    {
    	outp.println("_______________________________________________________________________________________________");
        outp.println("   		** Goodbye! Thank you for visiting the Fischer Chess Club! **     			 ");
        outp.println();
        outp.println(" Web: http://www.fischerchessclub.co.nr      Email: fcc@fischerchessclub.herobo.com ");
        outp.println(" Tel: (847)-548-7308");
        outp.println("_______________________________________________________________________________________________");
        outp.println();
    }
    
    public static void welcome(PrintStream outp)
    {
    	// Welcome the user with a cute little welcome screen.
        outp.println("    .::.    Welcome to the FISCHER CHESS CLUB");
        outp.println("    _::_ ");
        outp.println("  _/____\\_  Web: http://www.fischerchessclub.co.nr      Email: fcc@fischerchessclub.herobo.com ");
        outp.println("  \\      /  Tel: (847)-548-7308");
        outp.println("   \\____/   ___________________________________________________________________________________");
        outp.println("   (____)   ***********************************************************************************");                                                                                         
        outp.println("    |  |    *  IMPORTANT MESSAGE FROM STAFF:                                                  *");                                                                                          
        outp.println("    |__|    *                                                                                 *");                                                                                      
        outp.println("   /    \\   *  THE USE OF CHESS ENGINES, BOTS, OR ANY OTHER ANALYSIS DEVICES TO ASSIST YOU    *");                                                                     
        outp.println("  (______)  *  DURING YOUR PLAY IS SCRICTLY PROHIBITED. UNDER THE TERMS OF THE USER AGREEMENT *");
        outp.println(" (________) *  WE MAINTAIN THE RIGHT TO MONITOR THIS ACTIVITY AS NEEDED WITH THE AID OF LOGS  *");
        outp.println(" /________\\ *  AND OTHER SERVICES AT OUR DISPOSAL.                                            *");
        outp.println("            ***********************************************************************************");
        outp.println("_______________________________________________________________________________________________");
        outp.println();
    }
}
